package com.example.hssmgs.Student;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class DBOpenHelper extends SQLiteOpenHelper {

    public DBOpenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // 创建学生信息表语句
        String sql_student_db = "create table student_db(account varchar(20), id varchar(20))";
        // 学生密码表
        String sql_student_pw = "create table student_pw(account varchar(20), password varchar(20))";



        db.execSQL(sql_student_db);
        db.execSQL(sql_student_pw);

//        String sql_insert_pw1 = "insert into student_pw values ('1', 'yz'), ('2', 'haha')";
//        String sql_insert_db1 = "insert into student_db values ('1', '19990712')";


//        db.execSQL(sql_insert_pw1);
//        db.execSQL(sql_insert_db1);



        // 创建老师信息表语句
        String sql_teacher_db = "create table teacher_db(account varchar(20), id varchar(20))";
        // 创建老师密码
        String sql_teacher_pw = "create table teacher_pw(account varchar(20), password varchar(20))";



        db.execSQL(sql_teacher_db);
        db.execSQL(sql_teacher_pw);

//        String sql_insert_pw2 = "insert into teacher_pw values ('t1', 't1'), ('t2', 't2')";
//        String sql_insert_db2 = "insert into teacher_db values ('t1', 'teacher1')";


//        db.execSQL(sql_insert_pw2);
//        db.execSQL(sql_insert_db2);


        // 管理员账户
        String sql_admin_db = "create table teacher_db(account varchar(20), id varchar(20))";
        // 管理员密码表
        String sql_admin_pw = "create table teacher_pw(account varchar(20), password varchar(20))";



        db.execSQL(sql_admin_db);
        db.execSQL(sql_admin_pw);

//        String sql_insert_pw3 = "insert into admin_pw values ('root', 'root')";
//        String sql_insert_db3 = "insert into admin_db values ('root', 'admin')";


//        db.execSQL(sql_insert_pw3);
//        db.execSQL(sql_insert_db3);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
